<?php
	function process_url($url)
	{
		$ch = curl_init($url);
		curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE);
		curl_setopt($ch,CURLOPT_FOLLOWLOCATION,TRUE);
		$data = curl_exec($ch);
		$ret['data'] = $data;
		$ret['httpcode'] = curl_getinfo($ch, CURLINFO_HTTP_CODE);
		curl_close($ch);
		return $ret;
	}
	function checkpermiss($username,$admin_name,$list)
	{
		$url = "https://api.twitter.com/1/$admin_name/$list/members.json";
		do{
			$ret = process_url($url);
			if($ret['httpcode'] <> '200'){return false; }
			$retjson = $ret['data'];
			$list_members_info = json_decode($retjson);
			$next_cursor = $list_members_info->next_cursor_str;
			foreach($list_members_info->users as $user)
			{
				if(	$user->screen_name == $username	)
				{
					return true;
				}
			}
			$url = "https://api.twitter.com/1/$admin_name/$list/members.json?cursor=$next_cursor";
		}while($next_cursor <= 0);
		return false;
	}
?>